import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/table';
import { airportList } from '@apps/ant-bus/src/views/business/airport/data/api';
import { isEmpty } from '@pkg/utils';
import { RenderType } from '@pkg/setting';

export const columns: BasicColumn[] = [
  {
    title: '会员姓名',
    dataIndex: 'userName',
    width: 80,
  },
  {
    title: '手机号',
    dataIndex: 'mobile',
    width: 100,
  },
  {
    title: '退卡卡号',
    dataIndex: 'vipCardNo',
    width: 140,
  },
  {
    title: '退款日期',
    dataIndex: 'refundDate',
    width: 150,
  },
  {
    title: '退款金额',
    dataIndex: 'refundAmount',
    width: 100,
  },
  {
    title: '退卡工单状态',
    dataIndex: 'isCheck',
    width: 150,
    dictData: [
      { label: '现办现退失败', value: -2 },
      { label: '现办现退中', value: -1 },
      { label: '现办现退成功', value: 0 },
      { label: '已提交', value: 1 },
      { label: '取消提交', value: 2 },
      { label: '退卡专员审核中', value: 3 },
      { label: '退卡专员取消退卡', value: 4 },
      { label: '退款专员审核中', value: 6 },
      { label: '退款专员取消退卡', value: 7 },
      { label: '退款专员驳回请求', value: 8 },
      { label: '退款专员已退款', value: 9 },
      { label: '退款专员已补退', value: 10 },
      { label: '退款专员已退卡未退款', value: 11 },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '票务是否注销',
    dataIndex: 'ticketVipcardState',
    width: 150,
    dictData: [
      { label: '已注销', value: 1 },
      { label: '未注销', value: 2 },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '卡种名称',
    dataIndex: 'goodsName',
    width: 100,
  },
  {
    title: '所属地区',
    dataIndex: 'airportName',
    width: 140,
  },
  {
    title: '开卡日期',
    dataIndex: 'buyDate',
    width: 90,
  },
  {
    title: '支付价格',
    dataIndex: 'payAmount',
    width: 80,
  },
  {
    title: '升降级卡种价格',
    dataIndex: 'upgradePayAmount',
    width: 120,
  },
  {
    title: '所属销售',
    dataIndex: 'employeeName',
    width: 100,
  },
  {
    title: '合卡销售',
    dataIndex: 'heKaRemark',
    width: 100,
  },
  {
    title: '会员承担金额',
    dataIndex: 'vipBearAmount',
    width: 120,
  },
  {
    title: '退款银行',
    dataIndex: 'bank',
    width: 120,
  },
  {
    title: '退款卡号',
    dataIndex: 'bankNo',
    width: 120,
  },
  {
    title: '退款方式',
    dataIndex: 'refundWay',
    width: 100,
    dictData: [
      { label: '支付宝', value: 'refund_ali' },
      { label: '微信', value: 'refund_wx' },
      { label: '银行', value: 'refund_bank' },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '退卡原因',
    dataIndex: 'refundReason',
    width: 250,
  },
  {
    title: '备注说明',
    dataIndex: 'remark',
    width: 250,
  },
  {
    title: '贵宾厅使用明细扣费说明',
    dataIndex: 'remarkc',
    width: 250,
  },
  {
    title: '电子金使用明细扣费说明',
    dataIndex: 'remarkd',
    width: 250,
  },
  {
    title: '补退方式',
    dataIndex: 'addRefundWay',
    width: 100,
    dictData: [
      { label: '支付宝', value: 'refund_ali' },
      { label: '微信', value: 'refund_wx' },
      { label: '银行', value: 'refund_bank' },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '补退金额',
    dataIndex: 'addRefundAmount',
    width: 120,
  },
  {
    title: '补退备注',
    dataIndex: 'addRefundRemark',
    width: 150,
  },
  {
    title: '标记备注',
    dataIndex: 'tagRemark',
    width: 150,
  },
  {
    title: '提交人',
    dataIndex: 'submitUserName',
    width: 100,
  },
  {
    title: '申请日期',
    dataIndex: 'createTime',
    width: 150,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'userInfo',
    label: '会员信息',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'startDate',
    label: '申请开始日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'endDate',
    label: '申请结束日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'airportId',
    label: '机场',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: {
      api: airportList,
      params: { handlerName: 'busAirportRoleListHandler' },
      labelField: 'airportName',
      valueField: 'airportId',
      immediate: true,
      showSearch: true,
    },
  },
  {
    field: 'employeeInfo',
    label: '销售信息',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'isCheck',
    label: '审核状态',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        options: [
          { label: '现办现退失败', value: -2 },
          { label: '现办现退中', value: -1 },
          { label: '现办现退成功', value: 0 },
          { label: '已提交', value: 1 },
          { label: '取消提交', value: 2 },
          { label: '退卡专员审核中', value: 3 },
          { label: '退卡专员取消退卡', value: 4 },
          { label: '退款专员审核中', value: 6 },
          { label: '退款专员取消退卡', value: 7 },
          { label: '退款专员驳回请求', value: 8 },
          { label: '退款专员已退款', value: 9 },
          { label: '退款专员已补退', value: 10 },
          { label: '退款专员已退卡未退款', value: 11 },
        ],
        showSearch: true,
        filterOption: (input: string, option: any) => {
          return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
        },
      };
    },
  },
  {
    field: 'refundStartDate',
    label: '退款开始日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'refundEndDate',
    label: '退款结束日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'exportTimeType',
    label: '导出时间选择',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [
        { label: '按申请日期导出', value: 1 },
        { label: '按退款日期导出', value: 2 },
      ],
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '主键',
    field: 'backcardRecordId',
    component: 'Input',
    required: true,
    show: false,
  },
  {
    label: '审核状态',
    field: 'isCheck',
    component: 'Input',
    required: true,
    show: false,
  },
  {
    label: '承担方式',
    field: 'bearWay',
    component: 'RadioGroup',
    required: true,
    defaultValue: 1,
    componentProps: {
      options: [
        { label: '会员同意全部承担', value: 1 },
        { label: '会员不同意全部承担', value: 2 },
      ],
    },
    ifShow: ({ model }) => {
      if (model.isCheck == 6) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '会员承担金额',
    field: 'vipBearAmount',
    component: 'InputNumber',
    required: true,
    ifShow: ({ model }) => {
      if (model.isCheck == 6) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '销售承担金额',
    field: 'saleBearAmount',
    component: 'InputNumber',
    required: true,
    ifShow: ({ model }) => {
      if (model.isCheck == 6 && model.bearWay == 2) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '开户银行',
    field: 'bank',
    component: 'Input',
    required: true,
    ifShow: ({ model }) => {
      if (model.isCheck == 6) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '银行卡号',
    field: 'bankNo',
    component: 'Input',
    required: true,
    ifShow: ({ model }) => {
      if (model.isCheck == 6) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '退卡金额',
    field: 'refundAmount',
    component: 'InputNumber',
    required: true,
    ifShow: ({ model }) => {
      if (model.isCheck == 6) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '申请退卡备注',
    field: 'remark',
    component: 'InputTextArea',
    required: false,
    ifShow: ({ model }) => {
      if (model.isCheck == 6) {
        return true;
      } else {
        return false;
      }
    },
    dynamicDisabled: true,
  },
  {
    label: '退卡专员备注',
    field: 'remarka',
    component: 'InputTextArea',
    required: false,
    ifShow: ({ model }) => {
      if (model.isCheck == 6) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '贵宾厅使用明细扣费说明',
    field: 'remarkc',
    component: 'InputTextArea',
    required: false,
    ifShow: ({ model }) => {
      if (model.isCheck == 6) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '电子金使用明细扣费说明',
    field: 'remarkd',
    component: 'InputTextArea',
    required: false,
    ifShow: ({ model }) => {
      if (model.isCheck == 6) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '退卡原因',
    field: 'refundReason',
    component: 'InputTextArea',
    required: true,
    ifShow: ({ model }) => {
      if (model.isCheck == 6) {
        return true;
      } else {
        return false;
      }
    },
    dynamicDisabled: true,
  },
  {
    label: '驳回原因',
    field: 'remarkb',
    component: 'InputTextArea',
    dynamicDisabled: true,
    required: false,
    ifShow: ({ model }) => {
      if (!isEmpty(model.remarkb) && model.isCheck == 6) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '驳回原因',
    field: 'remarkb',
    component: 'InputTextArea',
    required: true,
    ifShow: ({ model }) => {
      if (model.isCheck == 8) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '退款方式',
    field: 'refundWay',
    component: 'Select',
    required: true,
    defaultValue: 'refund_bank',
    componentProps: ({ formModel }) => {
      return {
        options: [
          { label: '银行', value: 'refund_bank' },
          { label: '微信', value: 'refund_wx' },
          { label: '支付宝', value: 'refund_ali' },
          { label: '其他·', value: 'refund_order' },
        ],
      };
    },
    ifShow: ({ model }) => {
      if (model.isCheck == 9) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '备注',
    field: 'remarkb',
    component: 'InputTextArea',
    required: false,
    ifShow: ({ model }) => {
      if (model.isCheck == 9) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '退款凭证',
    field: 'refundImg',
    component: 'ImageUpload',
    ifShow: ({ model }) => {
      if (model.isCheck == 9) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '补退退款方式',
    field: 'addRefundWay',
    component: 'Select',
    required: true,
    defaultValue: 'refund_bank',
    componentProps: {
      options: [
        { label: '银行', value: 'refund_bank' },
        { label: '微信', value: 'refund_wx' },
        { label: '支付宝', value: 'refund_ali' },
        { label: '其他·', value: 'refund_order' },
      ],
    },
    ifShow: ({ model }) => {
      if (model.isCheck == 10) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '补退金额',
    field: 'addRefundAmount',
    component: 'InputNumber',
    required: true,
    ifShow: ({ model }) => {
      if (model.isCheck == 10) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '补退备注',
    field: 'addRefundRemark',
    component: 'InputTextArea',
    required: true,
    ifShow: ({ model }) => {
      if (model.isCheck == 10) {
        return true;
      } else {
        return false;
      }
    },
  },
  {
    label: '未退款备注',
    field: 'tagRemark',
    component: 'InputTextArea',
    required: true,
    ifShow: ({ model }) => {
      if (model.isCheck == 11) {
        return true;
      } else {
        return false;
      }
    },
  },
];
